package cn.wolfcode.mapper;

import cn.wolfcode.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    @Insert("""
            insert into user (username, password) values (
            #{username},#{password}
            )
            """)
    void add(User user);

    @Update("""
            update user set username = #{username},
                            password = #{password}
                            where id = #{id}
            """)
    void update(User user);
    @Delete("""
                            delete from user 
                                   where id = #{id}
            """)
    void delById(Long id);
    @Select("""
            select id, username, password
            from user
            where id = #{id}
            """)
    User getById(Long id);
        @Select("""
                select id, username, password
                            from user
                """)
    List<User> getAll();
}
